package org.zxp.effectiveJava.serializable;

import java.io.*;

public class SerializableUtils {
    private static final String PATH = "C://Users//zxpdt//javatest//serializable.ob";

    public static void write(Object obj) throws Exception {
        File f = new File(PATH);
        if(!f.exists()){
            f.createNewFile();
        }
        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(PATH));
        out.writeObject(obj);
        out.close();
    }

    public static Object read() throws Exception {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(
                new File(PATH)));
        return ois.readObject();
    }
}
